var express = require("express");

var app = express();
//设置模板引擎
var handlebars = require("express3-handlebars")
	.create({defaultLayout:"main"})

app.engine('handlebars',handlebars.engine)
app.set('view engine','handlebars')

//设置端口
app.set('port',process.env.PORT || 3000);


app.get('/',function(req,res){
	res.render('home')
	//res.type('text/plain')
	//res.send('Meadowlark Travel')
})

app.get('/about',function(req,res){
	res.render('about')
	//res.type('text/plain')
	//res.send('about')
})

//定义400
app.use(function(req,res) {
	res.type("text/plain")
	res.status(400)
	res.send('404 - Not Found')
});

//定义500
app.use(function(err,req,res,next){
	console.log(err.stack);
	res.type('text/plain')
	res.status(500)
	res.send('500 - Server Error')
});

//设定端口
app.listen(app.get('port'),function(){
	console.log("express started on http://localhost:"+app.get('port'))
})